# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2024/1/5 13:27
from lib2to3.pgen2 import driver

from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from datetime import datetime



class ProductContainerRegistryLocator:



   """
   my resource 页面
   """
   # my resource tab页面菜单列表
   my_resource_tab_list = (By.CSS_SELECTOR,'[class="antd4-tabs-tab-btn"]')
   # product 列表
   my_resource_product_list = (By.CSS_SELECTOR,'[class="productBtn___2kdzl"]')
   # create_new按钮
   move_storge_create_new = (By.XPATH,'(//button[@class="antd4-btn antd4-btn-primary"])[3]')

   #实例检查页面
   iframe_container_registry = (By.CSS_SELECTOR,'[id="hj_container"]')

   ###################### Block Storge #############################################
   """
    Container Registry页面
   """

   # 判断进入Container Registry页面
   if_enter_container_registry_page = (By.XPATH, '//*[@id="app"]/div[1]/div/div[3]/div/div[2]/div[1]/h3/span/span/span')
   # 点击access credential页面
   click_access_credential = (By.XPATH, '//*[@id="app"]/div[1]/div/div[3]/div/div[3]/div[1]/div[2]/ul/li[3]/div/span/a')
   #点击namespace页面
   click_namespace = (By.XPATH, '//*[@id="app"]/div[1]/div/div[3]/div/div[3]/div[1]/div[2]/ul/li[2]/div/span/a')
   # 点击Repositories页面
   click_repositories = (By.XPATH, '(//div[@class="next-menu-item-inner"])[2]')
   #点击create namespace
   click_create_namespace = (By.XPATH, '//*[@id="app"]/div[1]/div/div[3]/div/div[3]/div[2]/button/span')
   #namespace输入框
   input_namespace = (By.XPATH, '//*[@id="NamespaceName"]')
   #点击提交
   click_submit = (By.XPATH, '//*[@id="asconsole-container"]/div/div/div[2]/div/div[2]/button/span')
   #点击back to console
   click_back_to_console = (By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/button/span')
   #是否包含Obtain Credential元素
   if_obtain_credential = (By.XPATH, '//*[@id="app"]/div[1]/div/div[3]/div/div[3]/div[2]/div/div/div[1]/div[2]/div[1]')
   # 是否包含Login Instance元素
   if_login_instance = (By.XPATH,    '//*[@id="app"]/div[1]/div/div[3]/div/div[3]/div[2]/div/div/div[2]/div[2]/div[1]')
   #Recently Visited
   click_rv = (By.XPATH, '(//div[@class="columnItemNameRec___3-3Do"])[1]')



   #vpc页面
   #点击route tables
   click_route_tables = (By.XPATH, '(//span[@class="teamix-typography teamix-typography-ellipsis teamix-nav-console-sidebar-text"])[3]')
   #是否有overview
   if_overview = (By.XPATH, '(//span[@class="teamix-pro-page-header-title-name"])')
   #是否包含route tables
   if_route_tables = (By.XPATH, '(//div[@class="children-section-name"])')
   #是否包含Route Table ID/Name
   if_table_id = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node next-table-fix-left next-table-fix-left-last"])')
   #if_table_id = (By.XPATH, '//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/table/thead/tr/th[2]/div/text()')
   #是否包含tag
   #if_tag = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[3]')
   if_tag = (By.XPATH, '(//div[text()="Tag"])')
   #if_tag = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node"])[1]')
   #if_tag = (By.XPATH, '//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/table/thead/tr/th[3]/div')
   #是否包含vpc id
   #if_vpc_id = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[4]')
   if_vpc_id = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node"])[2]')
   #if_vpc_id = (By.XPATH, '//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/table/thead/tr/th[4]/div/text()')
   #点击create route table
   click_create_route_table = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])')
   #点击name输入框
   input_name = (By.XPATH, '(//input[@id="RouteTableName"])')
   #点击submit
   click_submit_button = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])')
   #点击ok
   click_ok = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])[2]')
   #是否有name
   if_name = (By.XPATH, '(//div[@class="as-name-editor-value"])[1]')
   #点击删除按钮
   click_delete = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[2]')
   #点击删除ok按钮
   click_delete_ok = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-dialog-btn"])')


   #安全组页面元素
   #菜单按钮
   click_menu_list = (By.CSS_SELECTOR,'[class="product-menu-tigger"]')
   #ecs按钮
   click_esc = (By.XPATH, '(//div[@class="columnItemSub___2H4Ze"])[2]')
   # container_register按钮
   click_container_register = (By.XPATH, '(//div[text()="Container Registry"])[1]')
   # 输入产品名称按钮
   input_proname = (By.XPATH, '(//input[@placeholder="Product Name"])[1]')
   #进入到新的页面
   iframe_ecs = (By.CSS_SELECTOR,'[id="hj_container"]')
   #安全组按钮
   click_security_groups = (By.XPATH, '(//span[@class="teamix-typography teamix-typography-ellipsis teamix-nav-console-sidebar-text"])[10]')
   #创建安全组
   click_create_security_groups = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])[1]')
   #安全组名称输入框
   input_security_group_name = (By.XPATH, '(//input[@id="SecurityGroupName"])')
   # 安全组名称输入框
   if_delete_succ = (By.XPATH, '(//div[@class="next-message next-message-success next-toast next-medium next-title-content next-overlay-inner next-message-wrapper "])[1]')
   #是否有安全组名称
   if_security_group_name = (By.XPATH, '(//span[@class="teamix-pro-ellipsis-content"])[2]')
   #点击删除安全组按钮
   click_delete_security_group = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[4]')
   #确认删除安全组按钮
   click_ensure_delete = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-warning next-dialog-btn"])')
   # 点击修改安全组按钮
   click_modify_security_group = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[2]')
   #清除原来的name
   delete_old_name = (By.XPATH, '(//span[@class="next-input-hint-wrap"])')
   #安全组修改名称输入框
   modify_security_group_name = (By.XPATH, '//*[@class="next-loading-wrap"]/div/form/div[1]/div[2]/div/div/div/span/input')
   #modify_security_group_name = (By.XPATH, '(//span[@class="next-input next-medium teamix-pro-field-layout-compact"])[5]')
   #修改ok按钮
   modify_ok = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-dialog-btn"])')
   ##点击展开搜索下拉栏
   search_ele = (By.XPATH, '(//span[@class="next-input next-medium next-select-inner"])[1]')
   ##搜索下拉栏选择第二个
   select_by_name_ele = (By.XPATH, '//div[@class="next-overlay-wrapper opened"]/div/ul/li[2]/div')
   ##搜索输入框
   search_by_name = (By.XPATH, '(//input[@placeholder="Search by security group name"])[1]')
   ##第一个返回的安全组name
   sg_one_ele = (By.XPATH, '(//span[@class="teamix-pro-ellipsis-content"])[2]')

   #查看安全组详情
   click_manage_rules = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[3]')
   #是否有action字段
   if_action = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node next-table-word-break-word next-table-fix-left next-table-fix-left-last"])[1]')
   #是否有nic type字段
   if_nic_type = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node next-table-word-break-word"])[1]')
   #是否有protocol type字段
   if_protocol_type = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node next-table-word-break-word"])[2]')
   #是否有authorization type字段
   if_authorization_Type = (By.XPATH, '(//th[@class="next-table-cell next-table-header-node next-table-word-break-word"])[3]')
   #返回安全组列表
   back_to_sglist = (By.XPATH, '(//i[@class="teamix-icon teamix-icon-return-line teamix-large teamix-pro-page-header-goback"])')

   #创建安全组规则
   click_create_rule = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])')
   # Port Range输入框
   input_port_range = (By.XPATH, '(//textarea[@type="textArea"])[1]')
   #input_port_range = (By.XPATH, '(//div[@class="teamix-pro-field teamix-pro-field-textarea"])[1]')
   # Authorization Object输入框
   input_authorization_object = (By.XPATH, '(//textarea[@type="textArea"])[2]')
   #input_authorization_object = (By.XPATH, '(//div[@class="teamix-pro-field teamix-pro-field-textarea"])[2]')
   #Port Range验证正确性
   if_port_range = (By.XPATH, '(//span[@class="teamix-pro-ellipsis-content"])[12]')
   #创建规则ok
   click_create_rule_ok = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-dialog-btn"])')
   #点击删除安全组按钮
   click_delete_rule = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[4]')
   #确认删除安全组按钮
   click_ensure_delete_rule = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-warning next-dialog-btn"])')
   #nodate
   if_nodate = (By.XPATH, '(//span[@class="teamix-pro-empty-content-title-text"])')
   #点击outbound
   click_outbound = (By.XPATH, '(//div[@class="next-tabs-tab-inner"])[5]')


   #点击vswitch
   click_vswitch = (By.XPATH, '(//span[@class="teamix-typography teamix-typography-ellipsis teamix-nav-console-sidebar-text"])[4]')
   #点击实例id
   click_vswitch_id = (By.XPATH, '(//div[@class="teamix-typography"])[1]')
   #基本信息
   if_basic = (By.XPATH, '(//div[@class="next-tabs-tab-inner"])[1]')
   #vswitch操作记录
   if_opt_records = (By.XPATH, '(//div[@class="next-tabs-tab-inner"])[2]')
   #收起左侧边栏按钮
   click_left_button = (By.XPATH, '(//div[@class="teamix-nav-sidebar-collapse"])')
   # 点击VPC id
   click_vpc_id = (By.XPATH, '(//div[@class="teamix-typography"])[1]')
   #点击创建ecs
   click_create_ecs = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[4]')
   #点击next or submit
   click_next_or_submit = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])')
   # 第1个ipv4输入框
   input_first_ipv4 = (By.XPATH, '(//span[@class="next-input next-medium asform-ipv4-number"])[1]')
   # 第2个ipv4输入框
   input_second_ipv4 = (By.XPATH, '(//span[@class="next-input next-medium asform-ipv4-number"])[2]')
   # 第3个ipv4输入框
   input_third_ipv4 = (By.XPATH, '(//span[@class="next-input next-medium asform-ipv4-number"])[3]')
   #第4个ipv4输入框
   input_forth_ipv4 = (By.XPATH, '(//span[@class="next-input next-medium"])[4]')
   # 第1次输入密码
   input_first_passwd = (By.XPATH, '(//span[@class="next-input next-medium"])[5]')
   # 第2次输入密码
   input_second_passwd = (By.XPATH, '(//span[@class="next-input next-medium"])[6]')
   # 输入instancename
   input_instance_name= (By.XPATH, '(//span[@class="next-input next-medium"])[8]')
   # 点击ecs ok
   click_ecs_ok = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])')
   #是否有ecs的实例名
   if_instance_name = (By.XPATH, '(//span[@class="teamix-pro-ellipsis teamix-pro-ellipsis-single-line teamix-pro-field-output-tooltip"])[2]')
   # 点击instance status
   click_instance_status = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-text next-menu-btn"])[1]')
   # 点击stop instance
   click_stop_instance = (By.XPATH, '(//div[@class="next-menu-item teamix-pro-action-menu-item"])[2]')
   # 确认stop instance
   click_ensure_stop_instance = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary next-btn-warning next-dialog-btn"])')
   #vswitch name搜索框rddsf
   input_vswitch_name = (By.XPATH, '(//input[@placeholder="Search by vSwitch name"])')
   #是否有rddsf的name
   if_rddsf = (By.XPATH, '(//span[text()="rddsf"])')
   # 点击search按钮
   click_search = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-normal is-hybridcloud"])[2]')

   # 是否有namespace
   if_namespace = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[1]')
   # 是否有permissons
   if_permissions = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[2]')
   # 是否有Status
   if_status = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[3]')
   # 是否有Automatically
   if_automatically = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[4]')
   # 是否有Repository
   if_repository = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[5]')
   # 是否有Actions
   if_actions = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[6]')
   #点击下载地址图标
   click_download_adress = (By.XPATH, '(//i[@class="next-icon next-icon-download next-medium"])[1]')
   # 显示地址Repository Address cr.registry.tbres.telkomsigma.co.id/a_c/test111
   if_adress = (By.XPATH, '(//span[@class="tableInnerClick margin-left wordBreak"])[1]')
   #是否有Copied
   if_copied = (By.XPATH, '(//div[@class="next-message next-message-success next-toast next-medium next-title-content next-overlay-inner next-message-wrapper "])[1]')
   # 点击repository name
   repository_status = (By.XPATH, '(//span[@class="statusFilter NORMAL"])')
   #点击repository name
   click_repository_name = (By.XPATH, '(//span[@class="wind-rc-truncate__truncated"])[2]')
   # 是否有Repository Name
   if_repository_name = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[1]')
   # 是否有Repository Address
   if_repository_address = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[2]')
   # 是否有Repository Region
   if_repository_region = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[3]')
   # 是否有Code Repository
   if_code_repository = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[4]')
   # 是否有Repository Type
   if_repository_type = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[5]')
   # 是否有Summary
   if_summary = (By.XPATH, '(//div[@class="next-col next-col-fixed-8 wind-rc-data-fields-item-label"])[6]')
   # 是否有guide
   if_guide = (By.XPATH, '(//div[@class="next-tabs-tab-inner"])[1]')
   # 是否有Description
   if_description = (By.XPATH, '(//div[@class="next-tabs-tab-inner"])[2]')
   #detail的状态
   if_detail_status = (By.XPATH, '(//span[@class="wind-rc-actions-item"])[4]')
   #返回按钮
   click_back = (By.XPATH, '(//i[@class="next-icon next-icon-wind-arrow-left next-medium sc-kpOJdX dyYDZE"])[1]')
   # 仓库类型
   if_rep_type = (By.XPATH, '(//div[@class="next-col wind-rc-data-fields-item-value"])[5]')
   #编辑仓库
   edit_rep = (By.XPATH, '(//span[@class="subTitle-extra"])[1]')
   #输入summary
   input_summary = (By.XPATH, '(//textarea[@id="Summary"])[1]')
   # 输入Description
   input_description = (By.XPATH, '(//textarea[@id="Detail"])[1]')
   # 提交仓库修改
   confirm_repedit = (By.XPATH, '(//button[@class="next-btn next-medium next-btn-primary is-wind"])[1]')
   # if_summary_value
   if_summary_value = (By.XPATH, '(//span[@class="wordBreak"])[4]')
   # if_Description_value
   if_description_value = (By.XPATH, '(//div[@class="next-tabs-tabpane active"])[1]')
   #选择public
   click_public = (By.XPATH, '(//span[@class="next-radio-label"])[1]')
   # 选择private或者public
   click_private = (By.XPATH, '(//span[@class="next-radio-label"])[2]')
   #点击admin
   click_admin = (By.XPATH, '(//span[@class="wind-rc-actions-item"])[1]')

   #点击saas-spi的instanceID
   click_instanceid = (By.XPATH, '(//a[text()="99653"])')
   #是否有Basic Information
   if_basic_info = (By.XPATH, '(//div[@class="title___3rzth"])[1]')
   # 是否有Application Information
   if_app_info = (By.XPATH, '(//div[@class="title___3rzth"])[2]')
   # 是否有Product Name
   if_product_name = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[1]')
   # 是否有Status
   if_product_status = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[2]')
   # 是否有Product Detail
   if_product_detail = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[3]')
   # 是否有Created Time
   if_created_time = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[4]')
   # 是否有Front End Url
   if_front_end_url = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[5]')
   # 是否有Admin Url
   if_admin_url = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[6]')
   # 是否有User Name
   if_user_name = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[7]')
   # 是否有Password
   if_password = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[8]')
   # 是否有Authorized Login
   if_authorized_login = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[9]')
   # 是否有Remark
   if_remark = (By.XPATH, '(//div[@class="cre-descriptions-nowrap"])[10]')

   #是否有modified
   if_modified = (By.XPATH, '(//div[@class="next-message-title"])')
   # 点击 切换Repository Type
   click_change_type = (By.XPATH, '(//span[@class="next-radio-inner unpress"])')

   #进入havip页面
   #是否有havip_id
   if_havip_id = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[2]')
   #是否有status
   if_havip_status = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[3]')
   #是否有IP address
   if_havip_ipaddress = (By.XPATH, '(//div[@class="next-table-cell-wrapper"])[5]')


